﻿using Nasty.Core.Attributes;
using SqlSugar;

namespace Nasty.Core.Entity.System
{
    [SugarTable("SysUserMessage", TableDescription = "用户消息")]
    public class UserMessage : StandardEntity<UserMessage>
    {
        /// <summary>
        /// 所属用户ID
        /// </summary>
        [NastyColumn(ColumnName = "UserId", ColumnDescription = "所属用户ID", IsNullable = true)]
        public string? UserId { get; set; }

        /// <summary>
        /// 第三方Id 用于记录第三方唯一特征，方便第三方查找
        /// </summary>
        [NastyColumn(ColumnName = "ThirdId", ColumnDescription = "第三方Id", IsNullable = true)]
        public string? ThirdId { get; set; }

        /// <summary>
        /// 标题
        /// </summary>
        [SugarColumn(ColumnName = "Title", ColumnDescription = "标题")]
        public string? Title { get; set; }

        /// <summary>
        /// 描述
        /// </summary>
        [SugarColumn(ColumnName = "Description", IsNullable = true, ColumnDescription = "描述")]
        public string? Description { get; set; }


        /// <summary>
        /// 是否已读
        /// </summary>
        [SugarColumn(ColumnName = "IsRead", ColumnDescription = "是否已读")]
        public bool IsRead { get; set; }

        /// <summary>
        /// 消息类型
        /// </summary>
        [SugarColumn(ColumnName = "MessageType", ColumnDescription = "消息类型")]
        public MessageType MessageType { get; set; }

        /// <summary>
        /// 自定义扩展字段
        /// </summary>
        [SugarColumn(ColumnName = "Extend", IsNullable = true, ColumnDescription = "自定义扩展字段")]
        public string? Extend { get; set; }


        public override void OnPreAdd()
        {
            base.OnPreAdd();
            this.IsRead = false;
        }
    }


    public enum MessageType : byte
    {
        /// <summary>
        /// 系统消息
        /// </summary>
        System = 1,
        /// <summary>
        /// 流程消息
        /// </summary>
        Flow = 2,
        /// <summary>
        /// 全体消息
        /// </summary>
        All = 9,
    }
}
